package asteroids.expressions;

import java.util.Map;

import asteroids.Ship;
import asteroids.types.*;

public class AdditionExpression extends MathBinaryExpression {

	public AdditionExpression(int line, int column, Expression e1, Expression e2) {
		super(line, column, e1, e2);
	}

	@Override
	public Type evaluate(Ship ship, Map<String, Type> globals) {
		if(ship != null)
			return new DoubleType(((DoubleType) getFirstExpression().evaluate(ship, globals)).getValue() + ((DoubleType) getSecondExpression().evaluate(ship, globals)).getValue());
		else
			return new DoubleType();
	}

	@Override
	public String toString() {
		return getFirstExpression().toString() + " + " + getSecondExpression().toString();
	}
}
